﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace 图书管理系统
{
    class BookService
    {
        public PageBean findBooksPage(int currentPage,int pageSize,int method,String content)
        {
            PageBean pb = new PageBean();
            try
            {
                BookDao bookDao = new BookDao();
                int count = bookDao.count(method,content);
                int totalPage = (int)Math.Ceiling(count * 1.0 / pageSize);
                List<Book> books = bookDao.findbooks(currentPage, pageSize, method, content);
                pb.Count = count;
                pb.Books = books;
                pb.TotalPage = totalPage;
                pb.PageSize = pageSize;
                pb.CurrentPage = currentPage;
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
               
            }
            return pb;
        }
    }
}
